package com.dlc.shop.systemtest.api.amount;

import com.dlc.shop.bean.model.OfflineHandleEvent;
import com.dlc.shop.bean.param.OfflineHandleEventAuditParam;
import com.dlc.shop.discount.common.model.Discount;
import com.dlc.shop.systemtest.constants.Constant;
import com.dlc.shop.systemtest.util.HttpUtil;

/**
 * @author lh
 */
public class DiscountApi {
    public static Long save(Discount discount, Boolean useMainShop){
        String url = Constant.SHOP_URL+"/admin/discount";
        return HttpUtil.post(url,discount,Long.class,useMainShop);
    }

    public static Discount info(Long discountId){
        String url = Constant.SHOP_URL+"/admin/discount/info/"+discountId;
        System.out.println(url);
        return HttpUtil.get(url,Discount.class);
    }

    /**
     * 新增满减活动
     */
    public static Long save(Discount discount) {
        String url = Constant.SHOP_URL + "/admin/discount";
        return HttpUtil.post(url, discount, Long.class);
    }

    /**
     * 修改满减活动
     */
    public static void update(Discount discount) {
        String url = Constant.SHOP_URL + "/admin/discount";
        HttpUtil.put(url, discount);
    }

    public static void delete(Long discountId){
        String url = Constant.SHOP_URL+"/admin/discount/"+discountId;
        HttpUtil.delete(url);
    }

    /**
     * 平台违规下架满减
     */
    public static void offline(OfflineHandleEvent offlineHandleEvent) {
        String url = Constant.PLATFORM_URL + "/platform/discount/offline";
        HttpUtil.post(url, offlineHandleEvent);
    }

    /**
     * 商家根据活动ID获取下架信息
     */
    public static OfflineHandleEvent getOfflineHandleEvent(Long discountId) {
        String url = Constant.SHOP_URL + "/admin/discount/getOfflineHandleEventByDiscountId/" + discountId;
        return HttpUtil.get(url, OfflineHandleEvent.class);
    }

    /**
     * 商家根据活动下架信息申请上架
     */
    public static void applyOnline(OfflineHandleEventAuditParam offlineHandleEventAuditParam) {
        String url = Constant.SHOP_URL + "/admin/discount/auditApply";
        HttpUtil.post(url, offlineHandleEventAuditParam);
    }

    /**
     * 平台根据活动ID获取下架信息
     */
    public static OfflineHandleEvent getOfflineHandleEventByDiscountId(Long discountId) {
        String url = Constant.PLATFORM_URL + "/platform/discount/getOfflineHandleEventByDiscountId/" + discountId;
        return HttpUtil.get(url, OfflineHandleEvent.class);
    }

    /**
     * 平台根据活动下架信息审核
     */
    public static void audit(OfflineHandleEventAuditParam offlineHandleEventAuditParam) {
        String url = Constant.PLATFORM_URL + "/platform/discount/auditDiscount";
        HttpUtil.post(url, offlineHandleEventAuditParam);
    }

}
